﻿<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>

    <title>简洁模式</title>
    <!--SQL编辑器-->
    <link href="../../../Scripts/CodeMirror/lib/codemirror.css" rel="stylesheet" />
    <link href="../../../Scripts/CodeMirror/addon/hint/show-hint.css" rel="stylesheet" />
    <script src="../../../Scripts/CodeMirror/lib/codemirror.js"></script>
    <script src="../../../Scripts/CodeMirror/addon/edit/matchbrackets.js"></script>
    <script src="../../../Scripts/CodeMirror/mode/sql/sql.js"></script>
    <script src="../../../Scripts/CodeMirror/addon/hint/show-hint.js"></script>
    <script src="../../../Scripts/CodeMirror/addon/hint/sql-hint.js"></script>
    <script src="../../../Scripts/LoadSql.js"></script>
    <script type="text/javascript" src="../../../Scripts/bootstrap/js/jquery.min.js"></script>
    <script src="../../../Scripts/QueryString.js" type="text/javascript"></script>
    <link href="../../../Scripts/easyUI145/themes/icon.css" rel="stylesheet" type="text/css" />
    <link href="../../../Scripts/easyUI145/themes/default/easyui.css" rel="stylesheet" type="text/css" />
    <link href="../../../../DataUser/Style/ccbpm.css" rel="stylesheet" type="text/css" />

    <!-- 引用通用的js文件. -->
    <script type="text/javascript" src="../../../Scripts/config.js"></script>
    <script type="text/javascript" src="../../../Comm/Gener.js"></script>
    <script src="DDLBar.js" type="text/javascript"></script>
    <script src="../../Admin.js"></script>
    <script type="text/javascript" language="javascript">
        //页面启动函数.
        $(function () {

            InitBar("Simple");

            var html = "";
            var mapExt = new Entity("BP.Sys.MapExt");
            mapExt.MyPK = GenerMapExtPK();
            var i = mapExt.RetrieveFromDBSources(); //从数据库来查询.

            //设置按钮是否可以用?
            if (i == 0) {
                $("#Btn_FullData").hide();
                $("#Btn_Delete").hide();
            }

            //格式化.
            mapExt.Tag4 = FormatSQL(mapExt.Tag4);

            //绑定数据源类型. 在填充的时候，设置数据源.
            var ens = new Entities("BP.Sys.SFDBSrcs");
            ens.RetrieveAll();
            GenerBindDDL("DDL_FK_DBSrc", ens, "No", "Name", mapExt.FK_DBSrc);

            //批量为复制.
            GenerFullAllCtrlsVal(mapExt);

            //去掉 ' 号。
            var tag = mapExt.Tag4;
            while (tag.indexOf('~') > 1) {
                tag = tag.replace("~", "'");
            }

            //按照文本计算.
            $("#TB_SQL").val(tag);
            editor.setValue($("#TB_SQL").val());

        });

        function Save() {

            //更新节点表单类型.
            var frmID = GetQueryString("FK_MapData");
            var keyOfEn = GetQueryString("KeyOfEn");

            var en = new Entity("BP.Sys.MapAttr", frmID + "_" + keyOfEn);
            en.SetPara("TBFullCtrl", "Simple");
            en.Update();

            var mapExt = new Entity("BP.Sys.MapExt");
            mapExt.MyPK = GenerMapExtPK();
            var n = mapExt.RetrieveFromDBSources(); //从数据库来查询.

            mapExt.CopyURL();  //从url里面copy数据.
            mapExt.CopyForm(); //从from里面copy数据.

            mapExt.ExtType = "FullData";
            mapExt.AttrOfOper = GetQueryString("KeyOfEn");
            mapExt.FK_MapData = GetQueryString("FK_MapData");

            mapExt.Tag4 = editor.getValue(); //设置主表的SQL.
            if (mapExt.Tag4.indexOf('@Key') == -1) {
                alert('保存错误：您必须有@Key变量，请参考帮助文件。');
                return;
            }

            if (mapExt.Update() == 0)
                mapExt.Insert();

            Reload();
        }
        function DBTypeChange() {

            var val = $("#DDL_DBType").val();
            if (val == 0) {
                $("#DBSrc").show();
            } else {
                $("#DBSrc").hide();
            }
        }
    </script>
    <style type="text/css">

        .style1 {
            height: 21px;
        }

        #bar {
            text-align: left;
        }
        .expcon{ font-size:14px; color:#0079d4; padding:5px 0px;}
    </style>
</head>
<body>
    <div id="bar">
    </div>
    <form id="cc">
        <div class="cs-content-box">
            <table id="table" style="width: 100%;">
                <tr>
                    <td>
                        数据源类型
                    </td>
                    <td>
                        <select id="DDL_DBType" name="DDL_DBType" onchange="DBTypeChange(this)">
                            <option value="0">执行SQL</option>
                            <option value="1">执行url返回JSON</option>
                            <option value="2">执行CCFromRef.js返回JSON</option>
                        </select>
                    </td>
                </tr>
                <tr id="DBSrc">
                    <td>
                        数据源
                    </td>
                    <td>
                        <select id="DDL_FK_DBSrc" name="DDL_FK_DBSrc">
                        </select>
                    </td>
                </tr>

                <tr>
                    <td colspan="2">
                        搜索列表数据源配置:
                    </td>
                </tr>
                <tr>
                    <td colspan="2" style="width: 100%;">
                        <textarea rows="4" name="TB_SQL" id="TB_SQL" style="width: 90%;"> </textarea>
                    </td>
                </tr>
                <tr>
                    <td colspan="2" style="width: 100%;">

                        <a href="javascript:ShowHidden('sqlexp')" class="expcon"> <img src="../../../Img/Btn/Help.gif" />表达式填写帮助: </a>

                        <div id='sqlexp' style='color: Gray; display: none'>
                            <fieldset>
                                <legend>填充SQL帮助:</legend>
                                <ul>
                                    <li>1. 设置一个查询的SQL语句，该SQL必须包含 No, Name 列, 用与展示快速补全的部分。</li>
                                    <li>2. 该SQL必须包含 @Key 关键字，@Key 输入文本框的值. </li>
                                    <li>3. SQL返回的列与其他字段名称保持一致，就可以完成控件数据的自动填充。</li>
                                    <li>4. 比如: SELECT No,Name FROM WF_Emp WHERE No LIKE '@Key%'</li>
                                    <li>5.为防止URL编码规定like的第一个%写成[%],如果like '%@Key%' 写成'[%]@Key%'</li>
                                </ul>

                                <legend>填充Url帮助:</legend>
                                <ul>
                                    <li>1. 设置URL，返回的必须是json格式。</li>
                                    <li>2. 比如: /App/Handler.ashx?DoType=Emps&Key=@Key </li>
                                    <li>3. @Key 是输入的关键字 </li>
                                </ul>


                                <legend>主表运行效果</legend>
                                <img id="HelpImg" src="1.Simple.png"  />
                            </fieldset>

                            <fieldset>
                                <legend>从表运行效果</legend>
                                <img id="HelpImg" src="1.Simple-1.png"/>
                            </fieldset>
                        </div>
                    </td>
                </tr>
            </table>
        </div>
    </form>
</body>
</html>
